package com.hongning.railway.ui.main.fragments.college.exam.itemviewmodel;

import android.databinding.Observable;
import android.databinding.ObservableField;
import android.databinding.ObservableInt;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;

import com.hongning.railway.entity.resbean.ResOptionBean;
import com.hongning.railway.ui.main.fragments.college.exam.ExamDetailFragment;
import com.hongning.railway.ui.main.fragments.college.exam.ExamDetailFragmentViewModel;
import com.hongning.railway.util.Apputils;

import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;
import me.goldze.mvvmhabit.binding.command.BindingConsumer;

/**
 * Author: zhangjing
 * DATA:2019-08-16 18:56
 * DESC:
 * email:zhangjingworkmol@163.com
 */
public class ExamItemViewModel extends ItemViewModel<ExamDetailFragmentViewModel> {
    public ObservableField<String> name = new ObservableField<>();
    public ObservableField<String> singlechoice = new ObservableField<>("单选");
    public ObservableField<String> a = new ObservableField<>();
    public ObservableField<String> b = new ObservableField<>();
    public ObservableField<String> c = new ObservableField<>();
    public ObservableField<String> d = new ObservableField<>();
    public ObservableField<String> e = new ObservableField<>();
    public ObservableField<String> f = new ObservableField<>();
    public ObservableInt avisiable = new ObservableInt(View.GONE);
    public ObservableInt bvisiable = new ObservableInt(View.GONE);
    public ObservableInt cvisiable = new ObservableInt(View.GONE);
    public ObservableInt evisiable = new ObservableInt(View.GONE);
    public ObservableInt dvisiable = new ObservableInt(View.GONE);
    public ObservableInt fvisiable = new ObservableInt(View.GONE);
    private ResOptionBean resOptionBean;
    private boolean isSingle = true;

    public boolean isSingle() {
        return isSingle;
    }

    public ResOptionBean getResOptionBean() {
        return resOptionBean;
    }

    public ExamItemViewModel(@NonNull ExamDetailFragmentViewModel viewModel, ResOptionBean resOptionBean) {
        super(viewModel);
        this.resOptionBean = resOptionBean;
        if (resOptionBean.getFirstsd()==0){
            singlechoice.set("单选");
            isSingle = true;
        }else {
            singlechoice.set("多选");
            isSingle = false;
        }
        name.set(Apputils.getBlankEmpty()+resOptionBean.getTopicContent());
        a.set("A、"+resOptionBean.getSubjectOptionsA());
        b.set("B、"+resOptionBean.getSubjectOptionsB());
        c.set("C、"+resOptionBean.getSubjectOptionsC());
        if (TextUtils.isEmpty(resOptionBean.getSubjectOptionsD())){
            dvisiable.set(View.GONE);
        }else {
            dvisiable.set(View.VISIBLE);
            d.set("D、"+resOptionBean.getSubjectOptionsD());
        }
        if (TextUtils.isEmpty(resOptionBean.getSubjectOptionsE())){
            evisiable.set(View.GONE);
        }else {
            evisiable.set(View.VISIBLE);
            e.set("E、"+resOptionBean.getSubjectOptionsE());
        }
        if (TextUtils.isEmpty(resOptionBean.getSubjectOptionsF())){
            fvisiable.set(View.GONE);
        }else {
            fvisiable.set(View.VISIBLE);
            f.set("F、"+resOptionBean.getSubjectOptionsF());
        }
    }
}
